<template>
	<view class="danganinfo">
		<view class="itembox" v-if="dangan.name">
			<view class="label">
				姓名
			</view>
			<view class="value">
				{{ dangan.name }}
			</view>
		</view>
		
		<view class="itembox" v-if="dangan.relationship">
			<view class="label">
				关系
			</view>
			<view class="value">
				{{ dangan.relationship }}
			</view>
		</view>
		
		<view class="itembox" v-if="dangan.birthday">
			<view class="label">
				生日
			</view>
			<view class="value">
				{{ dangan.birthday }}
			</view>
		</view>
		
		<view class="itembox" v-if="dangan.gender">
			<view class="label">
				性别
			</view>
			<view class="value">
				{{ dangan.gender | getGender }}
			</view>
		</view>
		
		<view class="itembox" v-if="dangan.top">
			<view class="label">
				身高
			</view>
			<view class="value">
				{{ dangan.top }}
			</view>
		</view>
		
		<view class="itembox" v-if="dangan.weight">
			<view class="label">
				体重
			</view>
			<view class="value">
				{{ dangan.weight }}
			</view>
		</view>
		
		<view class="itembox" v-if="dangan.yaowei">
			<view class="label">
				腰围
			</view>
			<view class="value">
				{{ dangan.yaowei }}
			</view>
		</view>
		
		<view class="itembox" v-if="dangan.issmoke">
			<view class="label">
				吸烟史
			</view>
			<view class="value">
				{{ dangan.issmoke }}
			</view>
		</view>
		
		<view class="itembox" v-if="dangan.isdriking">
			<view class="label">
				饮酒史
			</view>
			<view class="value">
				{{ dangan.isdriking }}
			</view>
		</view>
		
		<view class="itembox" v-if="dangan.liver">
			<view class="label">
				肝功能
			</view>
			<view class="value">
				{{ dangan.liver }}
			</view>
		</view>
		
		<view class="itembox" v-if="dangan.kidney">
			<view class="label">
				肾功能
			</view>
			<view class="value">
				{{ dangan.kidney }}
			</view>
		</view>
		
		<view class="itembox" v-if="dangan.marry">
			<view class="label">
				婚姻
			</view>
			<view class="value">
				{{ dangan.marry }}
			</view>
		</view>
		
		<view class="itembox" v-if="dangan.hasChildren">
			<view class="label">
				生育
			</view>
			<view class="value">
				{{ dangan.hasChildren }}
			</view>
		</view>
		
		<view class="listitem" v-if="dangan.guomin">
			<view class="title">
				药物过敏
			</view>
			<view class="namebox">
				<view class="name" v-for=" data in dangan.guomin" :key="data">
					{{ data }}
				</view>
			</view>
		</view>
		
		<view class="listitem" v-if="dangan.foodguomin">
			<view class="title">
				食物过敏
			</view>
			<view class="namebox">
				<view class="name" v-for=" data in dangan.foodguomin" :key="data">
					{{ data }}
				</view>
			</view>
		</view>
		
		<view class="listitem" v-if="dangan.foodguomin">
			<view class="title">
				食物过敏
			</view>
			<view class="namebox">
				<view class="name" v-for=" data in dangan.foodguomin" :key="data">
					{{ data }}
				</view>
			</view>
		</view>
		
		<view class="listitem" v-if="dangan.man">
			<view class="title">
				慢性病
			</view>
			<view class="namebox">
				<view class="name" v-for=" data in dangan.man" :key="data">
					{{ data }}
				</view>
			</view>
		</view>
		
		<view class="listitem" v-if="dangan.family">
			<view class="title">
				家族病史
			</view>
			<view class="namebox">
				<view class="name" v-for=" data in dangan.family" :key="data">
					{{ data }}
				</view>
			</view>
		</view>
		
		<view class="listitem" v-if="dangan.selfdone">
			<view class="title">
				个人习惯
			</view>
			<view class="namebox">
				<view class="name" v-for=" data in dangan.selfdone" :key="data">
					{{ data }}
				</view>
			</view>
		</view>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				dangan: {},
				did: ""
			}
		},
		filters: {
			getGender(val) {
				if(val == 1) {
					return "男"
				} else if(val == 2) {
					return "女"
				} else {
					return "保密"
				}
			},
		},
		computed: {
			token() {
				return this.$store.state.token
			}
		},
		onLoad(e) {
			let id = e.id
			if(id) {
				this.did = id 
				this.getDangAn()
			}
		},
		methods: {
			// 根据ID 查找档案
			async getDangAn() {
				let id = this.did
				let res = await this.$Request("/admin/getDanganByID", { id }, this.token)
				let code = res.data.code 
				if(code == 200) {
					this.dangan = res.data.data
				}
			},
		},
	}
</script>

<style scoped lang="scss">
	.danganinfo {
		width: 100%;
		padding: 10rpx 20rpx;
		box-sizing: border-box;
		.itembox {
			width: 100%;
			display: flex;
			align-items: center;
			font-size: 30rpx;
			padding: 10rpx 0;
			margin: 10rpx 0;
			border-bottom: 1px solid #f2f2f2;
			.label {
				width: 200rpx;
				padding-left: 30rpx;
				color: green;
			}
			.value {
				color: #007AFF;
			}
		}
		.listitem {
			width: 100%;
			font-size: 30rpx;
			padding: 10rpx 0;
			margin: 10rpx 0;
			border-bottom: 1px solid #f2f2f2;
			.title {
				width: 200rpx;
				padding-left: 30rpx;
				color: green;
			}
			.namebox {
				width: 100%;
				box-sizing: border-box;
				display: flex;
				flex-wrap: wrap;
				padding: 10rpx 30rpx;
				.name {
					color: #007eff;
					padding: 15rpx;
					border-radius: 30rpx;
					border: 1px solid #007eff;
					font-size: 20rpx;
					margin: 10rpx 20rpx;
				}
			}
		}
	}
</style>
